package com.atguigu.practice;

import java.util.Scanner;

public class FindTheFakeMoney {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while(scanner.hasNextInt()){
            int n=scanner.nextInt();
            if(n==0){
                break;
            }else{
                System.out.println(findFake(n));
            }
        }
    }
    public static int findFake(int n){
        if(n==1){
            return 0;
        }else if(n==2 || n==3) {
            return 1;
        }else if(n%3==0){
            return 1+findFake(n/3);
        }else{
            return 1+findFake(1+n/3);
        }
    }
}
